from flask import Flask, render_template, request
from flask_wtf import CSRFProtect
app =Flask(__name__)
CSRFProtect(app)

app.config['SECRET_KEY'] = 'dasgdajhw'
@app.route("/",methods=["GET","POST"])
def hello():
    # 如果get请求返回注册页面
    if request.method == "GET":
        return render_template("file15register.html")
    else:
        # 如果post请求，处理注册业务
        # 1.获取参数
        username = request.form.get("username")
        password = request.form.get("password")
        repassword = request.form.get("repassword")

        # 2.检验参数
        if not all([username,password,repassword]):
            return "参数填写不全"
        # 3.两次密码是否一致
        if password != repassword:
            return "两次密码输入不一致"
        # 4.返回注册成功
        return "恭喜你，注册成功"



if __name__ == '__main__':
    app.run(debug=True)